package com.zhuanzhuan.hero.user.facade;

import com.bj58.spat.scf.server.contract.annotation.ServiceBehavior;
import com.bj58.zhuanzhuan.zzentry.common.service.entity.ServiceHeaderEntity;
import com.bj58.zhuanzhuan.zzentry.common.service.entity.ZZOpenScfBaseResult;
import com.bj58.zhuanzhuan.zzentry.common.service.model.openEntry.ZZHeader;
import com.bj58.zhuanzhuan.zzentry.common.service.model.openEntry.ZZMethod;
import com.bj58.zhuanzhuan.zzentry.common.service.model.openEntry.ZZParam;
import com.zhuanzhuan.hero.user.dto.visit.SaveVisitRecordDTO;
import com.zhuanzhuan.hero.user.service.HeroUserVisitRecordService;
import com.zhuanzhuan.hero.user.util.ServiceHeaderUtil;
import com.zhuanzhuan.hero.user.vo.UserListItemVO;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName UserVisitRecordFacadeImpl
 * @Description
 * @Author hanjunjun
 * @Date 2024/7/2 14:59
 */
@ServiceBehavior
@Slf4j
public class UserVisitRecordFacadeImpl implements IUserVisitRecordFacade {

    @Resource
    private HeroUserVisitRecordService userVisitRecordService;

    @ZZMethod(value = "saveVisitRecord", desc = "保存访问记录", publicAccess = false)
    @Override
    public ZZOpenScfBaseResult<Boolean> saveVisitRecord(@ZZHeader ServiceHeaderEntity header,
        @ZZParam("param") @Valid SaveVisitRecordDTO saveVisitRecordDTO) {
        userVisitRecordService.saveVisitRecord(ServiceHeaderUtil.parseUid(header), saveVisitRecordDTO.getToUid());
        return ZZOpenScfBaseResult.buildSucc(true);
    }

    @ZZMethod(value = "queryVisitRecordList", desc = "查询访客记录列表", publicAccess = false)
    @Override
    public ZZOpenScfBaseResult<List<UserListItemVO>> queryVisitRecordList(@ZZHeader ServiceHeaderEntity header, Long homemakerUid) {
        return ZZOpenScfBaseResult.buildSucc(userVisitRecordService.queryVisitRecordList(ServiceHeaderUtil.parseUid(header), homemakerUid));
    }

    @ZZMethod(value = "clearVisitRecord", desc = "清空访客记录", publicAccess = false)
    @Override
    public ZZOpenScfBaseResult<Boolean> clearVisitRecord(@ZZHeader ServiceHeaderEntity header) {
        userVisitRecordService.clearVisitRecord(ServiceHeaderUtil.parseUid(header));
        return ZZOpenScfBaseResult.buildSucc( true);
    }
}
